package GUI;

import javax.swing.JFrame;
import javax.swing.JMenuBar;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;

import Common.Course;
import Common.CourseOfStudent;
import Common.Courses;
import Common.StudentClass;

import java.awt.Dimension;
import java.util.Vector;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
/**
 * 
 * @author AlonGluzman
 *This is a main menu for the Administrator type user
 */
public class AdminMainMenu extends JFrame {
		private JMenuBar menuBar=null;
		private JMenu mnSemesterTools=null;
	
		
		private JMenuItem mntmOpenNewSemester=null;
	//	private JMenuItem mntmAttributeCourseTo =null;
		private JMenuItem mntmAttributeClassTo = null;
		private JMenuItem mntmConfigureClasses = null;
		private JMenu mnExeptionalRequests = null;
		private JMenuItem mntmStudentRemovalFrom = null;
		private JMenuItem mntmTeacherAllocationTo = null;
		private JMenuItem mntmStudentAdditionTo = null;
		private JMenuItem logout = null;
		private JMenuItem mntmLockCurrentSemester = null;
		private JMenuItem mntmOpenNewClass = null;
		
		public Login myLoginFrame = null;
		public UserAdmin user;
		private AdminMainMenu amn=null;
	//	private boolean done=false;
		public static Dimension defaultDim;
		public AttributeClassToCourse AttClassToCourse=null;
		private ConfigureClass confClassScreen = null;
		private OpenNewSemester newSemesterScreen = null;
		private OpenNewClass newClassScreen=null;
		private SelectClassForEx selClassScreen = null;
		private StudentRemovalFromCourse studentRmvFrmCrsScreen = null;
		private SelectStudentForEx selStudForExScreen=null;
		
		private SelectClassForExAdd selClassExAddScreen = null;
		private SelectStudentForExAdd selStudForExAddScreen = null;
		private StudentAdditionToCourse selCrsForExAdd = null;
		
		private SubTeacherSelect teacherAllocScrn_1 = null;
		private SubTeacherSelCrs teacherAllocScrn_2 = null;
		private SubTeacherSelCls teacherAllocScrn_3 = null;
		private TeacherAllocationToClass teacherAllocScrn_4 = null;
		
		
		private int numOfChildren = 0;
		private AttributeClassToCourseSelClass ClsToCrsSelClass = null;
		private AttributeClassToCourseSelCrs ClsToCrsSelCrs = null;
		private AttributeClassToCourse ClsToCrs = null;
		//private ConfigureClass configClass = null;
		/**
		 * Creates the Menu bar for this menu, this menu includes drop menues and JmenuItems, each with
		 * his own action listener
		 * @return
		 */
		
		private JMenuBar createMenuBar()
		{
			if (menuBar==null)
			{
				menuBar = new JMenuBar();
				
				
				//Semester tools menu
				mnSemesterTools = new JMenu("Semester tools");
				mntmOpenNewSemester = new JMenuItem("Open new semester");	
				mntmOpenNewSemester.addActionListener(new java.awt.event.ActionListener()
				{	
					public void actionPerformed(java.awt.event.ActionEvent e)
				
					{
						System.out.println("mntmOpenNewSemester");
						
						newSemesterScreen = null;
						newSemesterScreen = getNewSemesterScreen();
						setContentPane(newSemesterScreen );
						
						//TODO what happends when a parent clicks "Open new semester" 
						
				}});
				
					
				mntmConfigureClasses = new JMenuItem("Configure classes");
				mntmConfigureClasses.addActionListener(new java.awt.event.ActionListener()
				{	
					public void actionPerformed(java.awt.event.ActionEvent e)
				
					{
						System.out.println("mntmConfigureClasses");
						user.dataAttSt.Classes=null;
						user.dataAttSt.UnattributedStud=null;
						myLoginFrame.client.handleMessageFromClientUI("ClassesQuery");
						while(user.dataAttSt.Classes==null);
						myLoginFrame.client.handleMessageFromClientUI("StudUnatQuery");
						while(user.dataAttSt.UnattributedStud==null);
				

						if(!user.dataAttSt.UnattributedStud.isEmpty())
							{

						if(user.dataAttSt.UnattributedStud.isEmpty())System.out.println("there is no unattributed students");
						//TODO what happends when a parent clicks "mntmAttributeClassTo" 
						//TODO add the panel
						
						confClassScreen = null;
						confClassScreen=getConfigureClass();

						
							confClassScreen=getConfigureClass();
							setContentPane(confClassScreen);
							}
						else JOptionPane.showMessageDialog(amn, "There is no  unattributed students ");
						
						
				}});
				
				
				
				//Exceptional requests menu
				
				
				
				mnExeptionalRequests = new JMenu("Exeptional requests");
				
				mntmStudentRemovalFrom = new JMenuItem("Student removal from course");
				mntmStudentRemovalFrom.addActionListener(new java.awt.event.ActionListener()
				{	
					public void actionPerformed(java.awt.event.ActionEvent e)
				
					{
						System.out.println("actionPerformed");
						user.DataForEx.Classes=null;
						myLoginFrame.client.handleMessageFromClientUI("ClassesQuery");
						while(user.DataForEx.Classes==null);
						user.DataForEx.StudentsWithCourses=null;
						myLoginFrame.client.handleMessageFromClientUI("StudentQueryForEx");
						while(user.DataForEx.StudentsWithCourses==null);
						user.DataForEx.done=false;
						myLoginFrame.client.handleMessageFromClientUI("StudentCoursesRemoveExQuery");
						while(!user.DataForEx.done);
						selClassScreen = null;
						selClassScreen = getSelClassScreen();
						setContentPane(selClassScreen);
					
						
						
						//	selStudForExScreen = getStudentScreen();
					//	studentRmvFrmCrsScreen = getstudentRmvFrmCrsScreen();
						
						
						//selStudentScreen=getSelStudentScreen();
						//setContentPane(selStudentScreen);
						//setContentPane(getstudentRmvFrmCrsScreen());
					
						//done=false;
						//myLoginFrame.client.handleMessageFromClientUI("StudentCoursesQueryForEx "+user.DataForEx.StudentsWithCourses.get(i).Sid);
						//while(done);
							//while(user.DataForEx.StudentsWithCourses.get(i).ListOfCourses==null);
						
						
						
				}});
				
				mntmTeacherAllocationTo = new JMenuItem("Teacher allocation to a class");
				mntmTeacherAllocationTo.addActionListener(new java.awt.event.ActionListener()
				{	
					public void actionPerformed(java.awt.event.ActionEvent e)
				
					{
						System.out.println("mntmTeacherAllocationTo");
						myLoginFrame.client.handleMessageFromClientUI("TeachersQuery");
						while(user.DataForEx.Teachers==null);
						user.DataForEx.CoursesOfClasses=null;
						myLoginFrame.client.handleMessageFromClientUI("CoursesOfClassesAdminQuery");
						teacherAllocScrn_1 = null;
						teacherAllocScrn_1 = getTeacherAllocScrn();
						setContentPane(teacherAllocScrn_1);
						
						//while(user.DataForEx.CoursesOfClasses==null);
						
						//TODO what happends when a parent clicks "mntmTeacherAllocationTo" 
						
						
						
				}
			});
				
				mntmStudentAdditionTo = new JMenuItem("Student addition to a course");
				mntmStudentAdditionTo.addActionListener(new java.awt.event.ActionListener()
				{	
					public void actionPerformed(java.awt.event.ActionEvent e)
				
					{
						System.out.println("mntmTeacherAllocationTo");
						user.DataForEx.Classes=null;
						myLoginFrame.client.handleMessageFromClientUI("ClassesQuery");
						while(user.DataForEx.Classes==null);
						user.DataForEx.StudentsWithCourses=null;
						myLoginFrame.client.handleMessageFromClientUI("StudentQueryForEx");
						while(user.DataForEx.StudentsWithCourses==null);
						user.DataForEx.RawCourses=null;
						myLoginFrame.client.handleMessageFromClientUI("CoursesAdminForExQuery");
						while(user.DataForEx.RawCourses==null);
						user.DataForEx.done=false;
						myLoginFrame.client.handleMessageFromClientUI("StudentCoursesAddExQuery");
						while(!user.DataForEx.done);
						//TODO what happends when a parent clicks "mntmTeacherAllocationTo" 
						selClassExAddScreen = null;
						selClassExAddScreen=getselClassExAddScreen();
						setContentPane(selClassExAddScreen);
						
				}
			});
				
				logout = new JMenuItem("Logout");
				  logout.addActionListener(new java.awt.event.ActionListener()
					{	
						public void actionPerformed(java.awt.event.ActionEvent e)
					
						{
							System.out.println("logout");
							if(myLoginFrame.LoginResult.equalsIgnoreCase("OK"))
							{
								myLoginFrame.client.handleMessageFromClientUI("logout "+myLoginFrame.UserName.getText().toString());
							}
							myLoginFrame.UserName.setText("");
							myLoginFrame.Password.setText("");
							myLoginFrame.setContentPane(myLoginFrame.getFirstPanel());
							myLoginFrame.setVisible(true);
							//idTextField.setText("");
							//userTypeTextField.setText("");
							myLoginFrame.LoginResult=null;
							myLoginFrame.UserType=null;
							setVisible(false);
							
							
							//TODO what happends when a parent clicks "mlogout" 
							
					}
				});
				
				
			}
				
				
			
			return menuBar;
		}
	/**
	 * 
	 * @return open new class JMenuItem to open a screen 
	 * of open new class
	 */
		
		
		private JMenuItem getOpenNewClass()
		{
			if(mntmOpenNewClass==null)
			{
				mntmOpenNewClass = new JMenuItem("Open new class");
				mntmOpenNewClass.addActionListener(new ActionListener() {
					public void actionPerformed(ActionEvent e) {
						newClassScreen = null;
						newClassScreen = getOpenNewClassScreen();
						setContentPane(newClassScreen );
						
						
					}
				});
				mnSemesterTools.add(mntmOpenNewClass);
				
			}
			return mntmOpenNewClass;
		}
		
		
		
		
		private void initialize()
		{
			
			this.setSize(defaultDim=new Dimension(600,600));
			this.setTitle("Administration main menu");
			this.setJMenuBar(createMenuBar());
		
			
			menuBar.add(mnSemesterTools);
			mnSemesterTools.add(mntmOpenNewSemester);
			
		
			
			mntmLockCurrentSemester =  getmntmLockCurrentSemester();
			
			

			mnSemesterTools.add(mntmLockCurrentSemester);
			
			JMenu mnEditExistingSemster = new JMenu("Edit existing semster tools");
			mnSemesterTools.add(mnEditExistingSemster);
			
			//AttClassToCourse=new AttributeClassToCourse();
			//AttClassToCourse.amn=this;
				
			mntmAttributeClassTo = new JMenuItem("Attribute class to a course");
			mnEditExistingSemster.add(mntmAttributeClassTo);
			mntmAttributeClassTo.addActionListener(new java.awt.event.ActionListener()
			{	
				public void actionPerformed(java.awt.event.ActionEvent e)
			
				{
					user.dataAttClassToCourse.RawCourses=null;
					user.dataAttClassToCourse.Teachers=null;
					System.out.println("mntmAttributeClassTo");
					myLoginFrame.client.handleMessageFromClientUI("CoursesAdminQuery");
					while(user.dataAttClassToCourse.RawCourses==null);
					myLoginFrame.client.handleMessageFromClientUI("TeachersQuery");
					while(user.dataAttClassToCourse.Teachers==null);
					myLoginFrame.client.handleMessageFromClientUI("ClassesQuery");
					while(user.dataAttClassToCourse.Classes==null);
					
					user.dataAttClassToCourse.CoursesOfStudOfClass=null;
					myLoginFrame.client.handleMessageFromClientUI("CoursesOfStudOfClassQuery");			
					while(user.dataAttClassToCourse.CoursesOfStudOfClass==null);
					user.dataAttClassToCourse.CoursesWithPreCourses=null;
					myLoginFrame.client.handleMessageFromClientUI("CoursesWithPreCoursesQuery");
					while(user.dataAttClassToCourse.CoursesWithPreCourses==null);
					myLoginFrame.client.handleMessageFromClientUI("StudentwithClassQuery");
					while(user.dataAttClassToCourse.StudentsWithClasses==null);

					user.dataAttClassToCourse.CoursesThatClassTaked=null;
					myLoginFrame.client.handleMessageFromClientUI("CoursesOfClassQuery");
					while(user.dataAttClassToCourse.CoursesThatClassTaked==null);

					

					//setContentPane(AttClassToCourse);
					ClsToCrsSelClass = null;
					ClsToCrsSelClass =  getClsToCrsSelClass();
					setContentPane(ClsToCrsSelClass);

					//need to show AttClassToCourse here
					
					
					//TODO what happends when a parent clicks "mntmAttributeClassTo" 
					
			}});
			
			
			mnSemesterTools.add(mntmConfigureClasses);
			mnSemesterTools.add(getOpenNewClass());
			menuBar.add(mnExeptionalRequests);
			mnExeptionalRequests.add(mntmStudentRemovalFrom);
			mnExeptionalRequests.add(mntmTeacherAllocationTo);
			mnExeptionalRequests.add(mntmStudentAdditionTo);
			menuBar.add(logout);

			getContentPane().setLayout(null);

			this.user=new UserAdmin();


			

			
		}
		
		
	/**
	 * constructor for this menu	
	 */
		
	
	public AdminMainMenu() 
	    {
		
	
		super();
		initialize();
		this.amn=this;
	    }
	
	public void setClassesForStudAtt (Vector<String> classes)
	{
		this.user.dataAttSt.Classes=classes;
		this.user.dataAttClassToCourse.Classes=classes;
		this.user.DataForEx.Classes=classes;
		for(int i=0;i<classes.size();i++)
		{
			System.out.println("\nClass: "+classes.get(i));
		}
	}
	
	public void setStudentsForStudAtt(Vector<StudentClass> s)
	{
		this.user.dataAttSt.UnattributedStud=s;
		
		if(!s.isEmpty())
			{
			
			for(int i=0;i<s.size();i++)
				{
				System.out.println("\nStudent: "+s.get(i).FirstName+" "+s.get(i).LastName+" "+s.get(i).Sid);
				}
			
			}
	}
	public void setRawCoursesForClassAtt(Vector <RawCourse>rc)
	{
		this.user.dataAttClassToCourse.RawCourses=rc;
		//this.user.DataForEx.RawCourses=rc;
		for(int i=0;i<rc.size();i++)
		{
		System.out.println("\n Seting Raw Course: "+rc.get(i).Cid+" "+rc.get(i).CourseName+" "+rc.get(i).StudHours+" "+rc.get(i).StudUnit);
		}
	}
	public void setRawCoursesAdminForExQuery(Vector <RawCourse>rc)
	{
		this.user.DataForEx.RawCourses=rc;
		//this.user.DataForEx.RawCourses=rc;
		for(int i=0;i<rc.size();i++)
		{
		System.out.println("\n Seting Raw Course: "+rc.get(i).Cid+" "+rc.get(i).CourseName+" "+rc.get(i).StudHours+" "+rc.get(i).StudUnit);
		}
	}
	public void setTeachersForClassAtt(Vector<TeacherClass> t)
	{
		this.user.dataAttClassToCourse.Teachers=t;
		this.user.DataForEx.Teachers=t;
		for(int i=0;i<t.size();i++)
		{
		System.out.println("\nTeacher " +t.get(i).tid+" "+t.get(i).FirstName+" "+t.get(i).LastName+" "+t.get(i).StudUnit+" "+t.get(i).CountTeachHours+" "+t.get(i).MaxTeachHours);
		}
		
	}
	public void setStudentsForEx(Vector<StudentClass> s)
	{
		this.user.DataForEx.StudentsWithCourses=s;
		
		for(int i=0;i<s.size();i++)
		{
			System.out.println("\nStudent: "+s.get(i).Sid+" "+s.get(i).FirstName+" "+s.get(i).LastName+" "+s.get(i).ClassId);
		}
	}
	public void setStudentCoursesForEx(Vector<Course> c,Vector<String> ids)
	{
		Course temp;
		StudentClass tempStud;
		this.user.DataForEx.CoursesOfAllStudents=new Courses();
		this.user.DataForEx.CoursesOfAllStudents.lOfCourses=c;
		this.user.DataForEx.ids=ids;
	
		for(int i=0;i<this.user.DataForEx.CoursesOfAllStudents.lOfCourses.size();i++)
		{
			temp=this.user.DataForEx.CoursesOfAllStudents.lOfCourses.get(i);
			for(int j=0;j<this.user.DataForEx.StudentsWithCourses.size();j++)
				
			{
				
				if(this.user.DataForEx.StudentsWithCourses.get(j).Sid.equalsIgnoreCase(ids.get(i)))
				{
					
					tempStud=this.user.DataForEx.StudentsWithCourses.get(j);
					System.out.println("\n add course: " +temp.getCname()+" to stud"+tempStud.Sid);
					//this.user.DataForEx.StudentsWithCourses.remove(j);
					
					if(this.user.DataForEx.StudentsWithCourses.get(j).ListOfCourses==null)
						this.user.DataForEx.StudentsWithCourses.get(j).ListOfCourses=new Courses();
					System.out.println("\n Test");
					this.user.DataForEx.StudentsWithCourses.get(j).ListOfCourses.lOfCourses.add(temp);
					
					
					break;
				}
			}
		}
		
		this.user.DataForEx.done=true;
		
	}
	public void setClassesCoursesForEx(Vector<CourseOfClass> c)
	{
		this.user.DataForEx.CoursesOfClasses=c;
		for(int i=0;i<c.size();i++)
		{
			System.out.println("\n CourseofClass:"+ c.get(i).Cid+" "+c.get(i).ClassID+" "+
					c.get(i).CourseName+" "+c.get(i).Semester+" "+c.get(i).StudHours+" "+
					c.get(i).StudUnit+" "+c.get(i).TeacherID+" "+c.get(i).Year);
		}
	}
	
	public ConfigureClass getConfigureClass()
	{
		
		if(confClassScreen==null)
		{
		confClassScreen = new ConfigureClass(this);
		confClassScreen.amn=this;
		
		confClassScreen.setSize(getMaximumSize());
		
		}
		return confClassScreen;
	}
	
	public OpenNewSemester getNewSemesterScreen()
	{
		if(newSemesterScreen==null)
		{   
			newSemesterScreen = new OpenNewSemester(this);
			newSemesterScreen.setLayout(null);
			newSemesterScreen.setSize(getMaximumSize());
			newSemesterScreen.myLoginFrame = myLoginFrame;
			newSemesterScreen.user = user;
			newSemesterScreen.amn = this;
			
		}
		return newSemesterScreen;
	}
	
	public OpenNewClass getOpenNewClassScreen()
	{
		if(newClassScreen==null)
		{
			newClassScreen = new OpenNewClass(this);
			newClassScreen.setSize(getMaximumSize());
			
			newClassScreen.setFrame(this);
			
			newClassScreen.myLoginFrame = myLoginFrame;
			newClassScreen.user = user;
			newClassScreen.amn = this;
			
			
		}
		
		return newClassScreen;
		
	}
	
	

	public SelectClassForEx getSelClassScreen()
	{
		if(selClassScreen==null)
		{
			selClassScreen = new SelectClassForEx(this);
			selClassScreen.myLoginFrame=this.myLoginFrame;
			selClassScreen.user=this.user;
			selClassScreen.setSize(getMaximumSize());
			selClassScreen.amn=this;
			
		}
		return selClassScreen;
	}
	
	public SelectStudentForEx getStudentScreen()
	{
		if(selStudForExScreen==null)
		{
			selStudForExScreen = new SelectStudentForEx(this);
			selStudForExScreen.myLoginFrame=this.myLoginFrame;
			selStudForExScreen.user=this.user;
			selStudForExScreen.setSize(getMaximumSize());
			selStudForExScreen.amn=this;
			
				
			
		}
		
		return selStudForExScreen;
	}
	
	
	
	public StudentRemovalFromCourse getstudentRmvFrmCrsScreen()
	{
		if(studentRmvFrmCrsScreen==null)
		{
			studentRmvFrmCrsScreen = new StudentRemovalFromCourse(this);
			studentRmvFrmCrsScreen.myLoginFrame=this.myLoginFrame;
			studentRmvFrmCrsScreen.user=this.user;
			studentRmvFrmCrsScreen.setSize(getMaximumSize());
			studentRmvFrmCrsScreen.amn=this;
			
			
		}
		return studentRmvFrmCrsScreen;
		
	}
	
	
	
	
	public SelectClassForExAdd getselClassExAddScreen()
	{
		if(selClassExAddScreen==null)
		{
			selClassExAddScreen = new SelectClassForExAdd(this);
			selClassExAddScreen.myLoginFrame=this.myLoginFrame;
			selClassExAddScreen.user=this.user;
			selClassExAddScreen.setSize(getMaximumSize());
			selClassExAddScreen.amn=this;
			
		}
		return selClassExAddScreen;
	}
	
	
	
	public SelectStudentForExAdd getselStudForExAddScreen()
	{
		if(selStudForExAddScreen==null)
		{
			selStudForExAddScreen = new SelectStudentForExAdd(this);
			selStudForExAddScreen.myLoginFrame=this.myLoginFrame;
			selStudForExAddScreen.user=this.user;
			selStudForExAddScreen.setSize(getMaximumSize());
			selStudForExAddScreen.amn=this;
			
				
			
		}
		
		return selStudForExAddScreen;
	}
	

	
	public StudentAdditionToCourse getselCrsForExAdd()
	{
		if(selCrsForExAdd==null)
		{
			selCrsForExAdd = new StudentAdditionToCourse(this);
			selCrsForExAdd.myLoginFrame=this.myLoginFrame;
			selCrsForExAdd.user=this.user;
			selCrsForExAdd.setSize(getMaximumSize());
			selCrsForExAdd.amn=this;
			
			
		}
		return selCrsForExAdd;
		
	}
	
	
	
	public void setNumOfChildren(int num)
	{
		numOfChildren=num;
	}
	
	public void setCoursesOfStudOfClass(Vector<CourseOfStudent> c)
	{
		this.user.dataAttClassToCourse.CoursesOfStudOfClass=c;
	}
	public void setPreCoursesForAtt (Vector<String[]>c)
	{
		this.user.dataAttClassToCourse.CoursesWithPreCourses=c;
		for(int i=0;i<c.size();i++)
		{
			System.out.println("\n Course with preCourse:"+ c.get(i)[0]+" "+ c.get(i)[0]);
		}
	}
	public void setStudentsWithClasses(Vector<StudentClass> s)
	{
		this.user.dataAttClassToCourse.StudentsWithClasses=s;
		for(int i=0;i<s.size();i++)
		{
			System.out.println("\n Student with class:"+ s.get(i).FirstName+" "+ s.get(i).ClassId);
		}
		
	}
	public void setResultAttStudAndClassToCourse(boolean b)
	{
		user.dataAttClassToCourse.ApprovalToAtt=b;
	}
	
	public void setreturnAppToLockSemester(boolean b)
	{
		user.dataAttClassToCourse.ApprovalLockSemester=b;
	}
	
	public JMenuItem getmntmLockCurrentSemester()
	{
		
		if(mntmLockCurrentSemester==null)
		{
			final AdminMainMenu amn=this;
			mntmLockCurrentSemester = new JMenuItem("Lock current semester for edit");
			mntmLockCurrentSemester.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent arg0) {
					
					user.dataAttClassToCourse.ApprovalLockSemester=false;
					myLoginFrame.client.handleMessageFromClientUI("UpdateLockToCurrentSemester");
					while(!user.dataAttClassToCourse.ApprovalLockSemester);
					JOptionPane.showMessageDialog(amn, "The Semester is locked succesfully");
				}
			});
			
		}
		return mntmLockCurrentSemester;
	}
	

	
		

	public SubTeacherSelect getTeacherAllocScrn()
	{
		if(teacherAllocScrn_1==null)
		{
			teacherAllocScrn_1 = new SubTeacherSelect(this);
			teacherAllocScrn_1.myLoginFrame=this.myLoginFrame;
			teacherAllocScrn_1.user=this.user;
			teacherAllocScrn_1.setSize(getMaximumSize());
			teacherAllocScrn_1.amn=this;
			
		}
		return teacherAllocScrn_1;
	}
	

	
	public SubTeacherSelCrs getTeacherAllocScrn_2()
	{
		if(teacherAllocScrn_2==null)
		{
			teacherAllocScrn_2 = new SubTeacherSelCrs(this);
			teacherAllocScrn_2.myLoginFrame=this.myLoginFrame;
			teacherAllocScrn_2.user=this.user;
			teacherAllocScrn_2.setSize(getMaximumSize());
			teacherAllocScrn_2.amn=this;
			
		}
		return teacherAllocScrn_2;
	}
	
	
	
	public SubTeacherSelCls getTeacherAllocScrn_3()
	{
		if(teacherAllocScrn_3==null)
		{
			teacherAllocScrn_3 = new SubTeacherSelCls(this);
			teacherAllocScrn_3.myLoginFrame=this.myLoginFrame;
			teacherAllocScrn_3.user=this.user;
			teacherAllocScrn_3.setSize(getMaximumSize());
			teacherAllocScrn_3.amn=this;
			
		}
		return teacherAllocScrn_3;
	}
	
	
	 
	public  TeacherAllocationToClass getTeacherAllocScrn_4()
	{
		if(teacherAllocScrn_4==null)
		{
			teacherAllocScrn_4 = new TeacherAllocationToClass(this);
			teacherAllocScrn_4.myLoginFrame=this.myLoginFrame;
			teacherAllocScrn_4.user=this.user;
			teacherAllocScrn_4.setSize(getMaximumSize());
			teacherAllocScrn_4.amn=this;
			
		}
		return teacherAllocScrn_4;
	}
	
	public AttributeClassToCourseSelClass getClsToCrsSelClass()
	{
		if(ClsToCrsSelClass==null)
		{
		ClsToCrsSelClass = new AttributeClassToCourseSelClass (this);
		ClsToCrsSelClass.myLoginFrame=this.myLoginFrame;
		ClsToCrsSelClass.user=this.user;
		ClsToCrsSelClass.setSize(getMaximumSize());
		ClsToCrsSelClass.amn=this;
		}
		return ClsToCrsSelClass;
	}
	

	
	public AttributeClassToCourseSelCrs getClsToCrsSelCrs()
	{
		if(ClsToCrsSelCrs==null)
		{
			ClsToCrsSelCrs = new AttributeClassToCourseSelCrs (this);
			ClsToCrsSelCrs.myLoginFrame=this.myLoginFrame;
			ClsToCrsSelCrs.user=this.user;
			ClsToCrsSelCrs.setSize(getMaximumSize());
			ClsToCrsSelCrs.amn=this;
		}
		return ClsToCrsSelCrs;
	}
	 
	

	public AttributeClassToCourse getClsToCrs()
	{
		if(ClsToCrs==null)
		{
			ClsToCrs = new AttributeClassToCourse (this);
			ClsToCrs.myLoginFrame=this.myLoginFrame;
			ClsToCrs.user=this.user;
			ClsToCrs.setSize(getMaximumSize());
			ClsToCrs.amn=this;
		}
		return ClsToCrs;
	}
	 
	
	public void setAppToCreateExReqStudRem(boolean b)
	{
		user.DataForEx.RequestCreated=b;
	}
	
	public void setCoursesOfClass(Vector<CourseOfClass> c)
	{
		user.dataAttClassToCourse.CoursesThatClassTaked=c;
	}
	public void setAppInsertStudentToClass(boolean b)
	{
		user.dataAttSt.UpdateExecuted=b;
	}
	public void setApproveToNewClass(boolean b)
	{
		user.Executed=b;
	}
		
	public void setApproveToNewSemester(boolean b)
	{
		user.Executed=b;
	}

	

}		
		
	
		
		
	
